package com.googlecode.delivery.test;

import java.io.File;
import java.net.URL;

import com.googlecode.delivery.core.impl.EnvironmentHelper;
import com.googlecode.delivery.model.Environment;

/**
 * @author Stephen Kay
 * 
 */
public class DataSet {
	/**
	 * @return
	 * @throws Exception
	 */
	public static Environment getEnvironment() throws Exception {
		URL propsUrl = DataSet.class.getResource("kst.properties");
		File envFile = new File(propsUrl.toURI());
		Environment env = EnvironmentHelper.create(envFile);
		return env;
	}

	/**
	 * @return
	 * @throws Exception
	 */
	public static File getWar() throws Exception {
		URL propsUrl = DataSet.class.getResource("sample-war.war");
		File artefact = new File(propsUrl.toURI());
		return artefact;
	}

	/**
	 * @return
	 * @throws Exception
	 */
	public static File getNotConfigurableWar() throws Exception {
		URL propsUrl = DataSet.class
				.getResource("sample-artifact/sample-ko.war");
		File artefact = new File(propsUrl.toURI());
		return artefact;
	}

	/**
	 * @return
	 * @throws Exception
	 */
	public static File getLib() throws Exception {
		URL propsUrl = DataSet.class
				.getResource("sample-artifact/jar/sample-lib.jar");
		File artefact = new File(propsUrl.toURI());
		return artefact;
	}

	public static File getLibConfig() throws Exception {
		URL propsUrl = DataSet.class.getResource("sample-lib/config");
		File artefact = new File(propsUrl.toURI());
		return artefact;
	}

	/**
	 * @return
	 * @throws Exception
	 */
	public static File getResourcesDir() throws Exception {

		String srcDir = DataSet.class.getResource(".").getFile().substring(0,
				 DataSet.class.getResource(".").getFile().indexOf("/target"));
		File outputDir = new File(srcDir+"/src/main/resources");
		return outputDir;
	}

	/**
	 * @return
	 * @throws Exception
	 */
	public static File getOutputDir() throws Exception {
		String srcDir = DataSet.class.getResource(".").getFile().substring(0,
				 DataSet.class.getResource(".").getFile().indexOf("/target"));
		File outputDir = new File(srcDir + "/target/test");
		return outputDir;
	}
}
